<script setup lang="ts">
interface HouseInfo {
  id: number
  image: string
  hasVR: boolean
  isRecommended: boolean
  title: string
  rooms: string
  area: string
  direction: string
  floor: string
  price: string
  unit: string
}

const props = defineProps<{
  houseInfo?: HouseInfo
}>()

const house = props.houseInfo as HouseInfo
</script>

<template>
  <div class="house-card">
    <div class="card-image">
      <img :src="house.image" :alt="house.title" />
      <div v-if="house.hasVR" class="vr-badge">VR</div>
      <div v-if="house.isRecommended" class="recommend-badge">必买好房</div>
    </div>
    <div class="card-content">
      <h4 class="house-title">{{ house.title }}</h4>
      <div class="house-info">
        <span class="rooms">{{ house.rooms }}</span>
        <span class="area">{{ house.area }}</span>
        <span class="direction">{{ house.direction }}</span>
      </div>
      <div class="house-desc">{{ house.floor }}</div>
      <div class="price-info">
        <span class="price">{{ house.price }}</span>
        <span class="unit">{{ house.unit }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.house-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 160px;
  flex-shrink: 0;
  border: 1px solid #f0f0f0;
  padding-bottom: 20px;
  margin-bottom: 20px;

  .card-image {
    position: relative;
    width: 100%;
    height: 120px;
    flex-shrink: 0;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .vr-badge {
      position: absolute;
      top: 6px;
      left: 6px;
      background: rgba(0, 0, 0, 0.7);
      color: white;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 10px;
      font-weight: bold;
    }

    .recommend-badge {
      position: absolute;
      top: 6px;
      right: 6px;
      background: #ff6b35;
      color: white;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 10px;
    }
  }

  .card-content {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 0;

    .house-title {
      font-size: 13px;
      font-weight: bold;
      color: #333;
      margin: 0 0 3px 0;
      line-height: 1.2;
    }

    .house-info {
      display: flex;
      gap: 6px;
      margin-bottom: 3px;

      span {
        font-size: 11px;
        color: #666;
      }
    }

    .house-desc {
      font-size: 10px;
      color: #999;
      margin-bottom: 4px;
      line-height: 1.3;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .price-info {
      display: flex;
      align-items: baseline;
      gap: 6px;

      .price {
        font-size: 14px;
        font-weight: bold;
        color: #ff6b35;
      }

      .unit {
        font-size: 11px;
        color: #999;
      }
    }
  }
}
</style>
